package spring.awareioc;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class AwareBeanName implements BeanNameAware, ApplicationContextAware {
    private String name;

    public void setBeanName(String name) {
        System.out.println("AwareBeanName:" + name);
        this.name = name;

    }

    public void setApplicationContext(ApplicationContext app)
            throws BeansException {
        System.out.println("setApplicationContext:" + app.getBean(name));
    }

}
